VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
  Persistable = 0  'NotPersistable
  DataBindingBehavior = 0  'vbNone
  DataSourceBehavior  = 0  'vbNone
  MTSTransactionMode  = 0  'NotAnMTSObject
END
Attribute VB_Name = "clsGetHeader"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
Option Explicit

Public Function GetHeaderData() As Boolean

'   This function reads the xml string and extracts the values required
'   to update and insert into the
'   DIR_INTERFACE_INDEX table and puts them into the public IdxVars type

'xml Objects
Dim xmldoc      As MSXML2.DOMDocument
Dim nlKeytax    As MSXML2.IXMLDOMNodeList
Dim nlRequestor As MSXML2.IXMLDOMNodeList
Dim nlTracking  As MSXML2.IXMLDOMNodeList
Dim nKeyTax     As MSXML2.IXMLDOMNode
Dim nRequestor  As MSXML2.IXMLDOMNode
Dim nTracking   As MSXML2.IXMLDOMNode

Dim elKeyTax    As MSXML2.IXMLDOMElement
Dim elTracking  As MSXML2.IXMLDOMElement


'Other
Dim i As Integer
Dim strErrMsg As String
Dim strXmlString As String
Dim KeyTaxType As String

On Error GoTo PROC_ERROR

'changed by barb
Set xmldoc = New MSXML2.DOMDocument

XMLString = ReplaceTESTRefs(XMLString)

If Not xmldoc.loadXML(XMLString) Then
    Err.Raise vbObjectError, "CancelDirective.clsGetHeader.GetHeaderData", _
              "Error occurred while loading Header XML. " & xmldoc.parseError.reason
End If


Set nKeyTax = xmldoc.selectSingleNode("//KeyTax")
Set elKeyTax = nKeyTax
KeyTaxType = elKeyTax.getAttribute("Type")

'Get Requestor data
Set nlRequestor = xmldoc.selectNodes("//KeyTax/Requestor/*")

For i = 0 To nlRequestor.length - 1
    Set nRequestor = nlRequestor.Item(i)
    Select Case nRequestor.nodeName
            Case "Date"
                dtDate = NullOrValue(nlRequestor.Item(i).nodeTypedValue)
            Case "Time"
                dtTime = NullOrValue(nlRequestor.Item(i).nodeTypedValue)
            Case "Name"
                sName = NullOrValue(nlRequestor.Item(i).nodeTypedValue)
            Case "UserID"
                strUser = NullOrValue(nlRequestor.Item(i).nodeTypedValue)
            Case "email"
                sEmailTo = NullOrValue(nlRequestor.Item(i).nodeTypedValue)
    End Select
Next i

'Get Tracking data
Set nlTracking = xmldoc.selectNodes("/KeyTax/Tracking/*")

For i = 0 To nlTracking.length - 1
    Set nTracking = nlTracking.Item(i)
    Set elTracking = nlTracking.Item(i)
    Select Case nTracking.nodeName
            Case "RequestStatus"
                nReqStatus = NullOrValue(nlTracking.Item(i).nodeTypedValue)
            Case "Company"
                nComId = NullOrValue(elTracking.getAttribute("ID"))
            Case "BusinessUnit"
                nBuId = NullOrValue(elTracking.getAttribute("ID"))
            Case "Message"
                nMsgId = NullOrValue(elTracking.getAttribute("ID"))
            Case "Reference"
                nReferenceId = NullOrValue(elTracking.getAttribute("ID"))
            Case "KeytaxRequestNumber"
                nReqSeqNum = NullOrValue(nlTracking.Item(i).nodeTypedValue)
    End Select
Next i

GetHeaderData = True

'clean up
Set xmldoc = Nothing
Set nlKeytax = Nothing
Set nlRequestor = Nothing
Set nlTracking = Nothing
Set nRequestor = Nothing
Set nTracking = Nothing
Set elKeyTax = Nothing
Set elTracking = Nothing

PROC_EXIT:
  Exit Function

PROC_ERROR:
  GetHeaderData = False
  Err.Raise Err.Number, _
            "clsGetHeader/GetHeaderData", _
            Err.Description
            
Resume PROC_EXIT

End Function 'GetHeaderData
Private Function NullOrValue(varValue As Variant) As String

    If Not IsNull(varValue) Then
        If Len(Trim(varValue)) <> 0 Then
           NullOrValue = varValue
        Else
            NullOrValue = "NULL"
        End If
    Else
        NullOrValue = "NULL"
    End If

End Function


